home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / FNTNS / LOG2.ASM < prev    next >
Assembly Source File  |  1989-01-24  |  1KB  |  32 lines

  1. ;
  2. ; This program originally available on the Motorola DSP bulletin board.
  3. ; It is provided under a DISCLAMER OF WARRANTY available from
  4. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  5. ; Logarithm Base 2 by Polynomial Approximation
  6. ; Last Update 26 Jan 87   Version 1.0
  7. ;
  8. log2    macro
  9. log2    ident   1,0
  10. ;
  11. ;       Does a LOG2 by polynomial aproximation. 8 Bit accuracy.
  12. ;       LOG2(x)= 4.0* (-.3372223 x*x + .9981958 x - .6626105)
  13. ;                         a2             a1            a0
  14. ;       valid for:  .5<= x < 1.0
  15. ;
  16. ;       input value in x0, output in register A.
  17. ;
  18. ;       r1 initially points to the coefficients in y memory in this
  19. ;       order: a1,a2,a0
  20. ;
  21.         mpyr    x0,x0,a  y:(r1)+,y0     ;x**2, get a1
  22.         mpy     x0,y0,a  a,x1 y:(r1)+,y0        ;a1*x, mv x**2, get a2
  23.         mac     x1,y0,a  y:(r1)+,y0     ;a2* x**2, get a0
  24.         add     y0,a                    ;add in a0
  25.         asl     a                       ;mul by 2
  26.         asl     a                       ;mul by 4
  27.         rnd     a                       ;round result
  28.         endm
  29.                
  30.